/**
 * Created by barrett on 8/28/14.
 */

var mysql = require('mysql');
var dbconfig = require('../config/database');

var connection = mysql.createConnection(dbconfig.connection);

connection.query('CREATE DATABASE ' + dbconfig.database);

connection.query(
	'CREATE TABLE `' + dbconfig.database + '`.`' + dbconfig.users_table + '` ( \
  		`id` varchar(50) NOT NULL,\
  		`add_time` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),\
  		`enabled` bit(1) NOT NULL,\
  		`name` varchar(255) DEFAULT NULL,\
  		`password` varchar(255) DEFAULT NULL,\
  		`update_time` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),\
  		`username` varchar(255) DEFAULT NULL,\
  		PRIMARY KEY (`id`)\
	) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4');

console.log('Success: Database Created!')

connection.end();
